import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import url from "rollup-plugin-url";

export default {
  input: "src/index.js",
  output: {
    file: "dist/bundle.js",
    format: "umd",
  },
  plugins: [
    resolve({
      browser: true,
      preferBuiltins: true,
    }),
    commonjs({
      // global keyword handling causes Webpack compatibility issues, so we disabled it:
      // https://github.com/mapbox/mapbox-gl-js/pull/6956
      ignoreGlobal: true,
    }),
    url({
      // 设置要处理的文件类型和输出目录
      include: ["**/*.svg", "**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif"],
      limit: 10 * 1024, // 小于10KB的文件会转换为Base64编码
      emitFiles: false, // 生成文件到输出目录
      fileName: "[name][extname]", // 文件名格式
    }),
  ],
};
